var t = require("../../res/www.a9a.cn.js"),
  n = getApp(),
  a = wx.getStorageSync("COOK_U");
Page({
  data: { ic: 0, ARR: [] },
  onLoad: function (a) {
    var e = this;
    n.get_config("_ZEAI").then(function (o) {
      e.setData({ color: o.color, rgbcolor: t.c16_rgb(o.color), qid: a.qid }),
        n.chklogin().then(function (t) {
          t ||
            wx.showModal({
              content: rs.msg,
              confirmColor: e.data.color,
              confirmText: "朕知道了",
              showCancel: !1,
              success: function (t) {
                wx.navigateBack();
              },
            });
        });
    });
  },
  contentFn: function (t) {
    var n = t.detail.value.length;
    n > 140 &&
      (wx.showToast({ title: "最多140字", icon: "none", mask: !0 }), (n = 140)),
      this.setData({ ic: n });
  },
  upFn: function () {
    var t = this,
      n = 6 - parseInt(this.data.ARR.length);
    n <= 0
      ? wx.showToast({ title: "最多上传6张图片哦", icon: "none", mask: !0 })
      : wx.chooseMedia({
          count: n,
          mediaType: ["image"],
          sizeType: ["compressed"],
          sourceType: ["album", "camera"],
          success: function (n) {
            for (var a = t.data.ARR, e = [], o = 0; o < n.tempFiles.length; o++)
              e.push(n.tempFiles[o].tempFilePath);
            (a = a.concat(e)), t.setData({ ARR: a });
          },
        });
  },
  delFn: function (n) {
    var a = n.currentTarget.dataset.url,
      e = t.json_remove(this.data.ARR, a);
    this.setData({ ARR: e });
  },
  add_submitFn: function (e) {
    var o = this,
      i = e.detail.value.content;
    t.empty(i) || i.length > 140
      ? wx.showToast({ title: "亲，该说点什么吧～", icon: "none", mask: !0 })
      : wx.showModal({
          title: "温馨提醒",
          content:
            "确定提交么？\n以下情形话题将被删除或封号：\n1．请勿留下任何形式联系方法\n2．请勿发表涉黄涉政相关言论\n3．请勿发表辱骂攻击他人言论",
          confirmColor: o.data.color,
          cancelText: "取消",
          confirmText: "确定",
          success: function (e) {
            if (e.confirm) {
              var s = o.data.ARR,
                c = s.length;
              if (c > 0) {
                var r = Array(),
                  d = 0;
                !(function e() {
                  wx.showLoading({
                    title: "正在上传..第" + parseInt(d + 1),
                    mask: !0,
                  }),
                    wx.uploadFile({
                      url: n.WWW + "/api/wxxcx/qun.php",
                      filePath: s[d],
                      name: "pic",
                      formData: {
                        submitok: "trend_add_uppic",
                        openid: a.openid,
                        qid: o.data.qid,
                      },
                      success: function (s) {
                        if (1 == (s = t.jsoneval(s.data)).flag)
                          if ((d++, r.push(s._s), d < c))
                            setTimeout(function () {
                              e();
                            }, 300);
                          else {
                            wx.hideLoading();
                            var l = r.join(",");
                            n.ajax({
                              url: "qun.php",
                              data: {
                                submitok: "trend_add",
                                content: i,
                                piclist: l,
                                openid: a.openid,
                                qid: o.data.qid,
                              },
                              success: function (t) {
                                1 == t.flag
                                  ? (wx.hideLoading(),
                                    wx.showToast({
                                      title: t.msg,
                                      mask: !0,
                                      duration: 3e3,
                                    }),
                                    setTimeout(function () {
                                      o.goBack();
                                    }, 3e3))
                                  : wx.showToast({
                                      title: t.msg,
                                      icon: "none",
                                      mask: !0,
                                    });
                              },
                            });
                          }
                        else
                          wx.showModal({
                            content: s.msg,
                            confirmColor: o.data.color,
                            confirmText: "朕知道了",
                            showCancel: !1,
                            success: function (t) {
                              wx.navigateBack();
                            },
                          });
                      },
                    });
                })();
              } else
                n.ajax({
                  url: "qun.php",
                  data: {
                    submitok: "trend_add",
                    content: i,
                    openid: a.openid,
                    qid: o.data.qid,
                  },
                  success: function (t) {
                    1 == t.flag
                      ? (wx.showToast({
                          title: t.msg,
                          mask: !0,
                          duration: 3e3,
                        }),
                        setTimeout(function () {
                          o.goBack();
                        }, 3e3))
                      : wx.showToast({ title: t.msg, icon: "none", mask: !0 });
                  },
                });
            }
          },
        });
  },
  goBack: function () {
    var t = getCurrentPages();
    t[t.length - 2].trend_topFn(), wx.navigateBack({ delta: 1 });
  },
});
